<form class="layui-form layui-card" data-table-id="MenuTable" action="{:sysuri()}" data-auto="true" onSubmit="return false" method="post">

    <div class="layui-card-body">

       

        <div class="layui-form-item">
            <label class="layui-form-label">章节名称</label>
            <div class="layui-input-block">
                <input name="name" value='{$vo.name|default=""}'  lay-verify="required" placeholder="请输入章节名称" class="layui-input">
            </div>
        </div>

        <!-- 课程 -->
        <div class="layui-form-item">
            <label class="layui-form-label">课程</label>
            <div class="layui-input-block">
                <select name="parent_id"  id="product" lay-verify="required"  lay-search lay-verify="required">
                    <option value="">- 选择课程 -</option>
                    {volist name="product_list" id='product'}
                        <option value="{$product.id}" {if isset($vo.parent_id) && $vo.parent_id == $product.id} selected {/if}>{$product.name}</option>
                    {/volist}
                </select>
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label">排序</label>
            <div class="layui-input-block">
                <input name="sort" value='{$vo.sort|default="1"}'  lay-verify="required" placeholder="请输入排序" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
              <textarea placeholder="请输入备注" name="description" class="layui-textarea">{$vo.remark|default=''}</textarea>
            </div>
        </div>



     
        <!-- <div class="layui-form-item" >
            <label class="layui-form-label">图片</label>
            <div class="layui-input-block">
                <table class="layui-table layui-col-xs6">
                    <thead>
                    <tr>
                        <th class="text-center">上传图片</th>
                    </tr>
                    <tr>
                        <td width="90px" class="text-center"><input name="thumb" type="hidden" value="{$vo.thumb|default=''}"></td>
                    </tr>
                    </thead>
                </table>
                <script>$('[name="thumb"]').uploadOneImage()</script>
            </div>

        </div> -->

     



    </div>

    <div class="hr-line-dashed"></div>
    {notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}

    <div class="layui-form-item text-center">
        <button class="layui-btn" lay-submit type='submit'>保存数据</button>
        <button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗？" data-close>取消编辑</button>
    </div>
</form>

{block name='script'}
<script>
    layui.use(['form', 'laydate'], function(){
    var form = layui.form;
    var laydate = layui.laydate;
    var $ = layui.$;

    // 日期选择器初始化
    laydate.render({
        elem: '#ID-laydate-range',
        range: ['#ID-laydate-start-date', '#ID-laydate-end-date']
    });

    // 监听课程选择
    form.on('select(productSelect)', function(data){
        var productId = data.value;
        $('#classes').html('<option value="">加载中...</option>');
        $('#users').html('<option value="">请先选择班级</option>');
        form.render('select');
        if (productId) {
            $.post("{:url('content/class_plan/sys_get_class')}", {product_id: productId}, function(res){
                if (res.code == 1) {
                    var html = '<option value="">- 请选择班级-</option>';
                    res.data.forEach(function(item){
                        html += '<option value="' + item.id + '">' + item.name + '</option>';
                    });
                    $('#classes').html(html);
                } else {
                    layer.msg(res.info || '班级加载失败');
                }
                form.render('select');
            });
        }
    });

    // 监听班级选择
    form.on('select(classSelect)', function(data){
        var classId = data.value;
        $('#users').html('<option value="">加载中...</option>');
        form.render('select');

        if (classId) {
            $.post("{:url('content/class_plan/sys_get_user')}", {class_id: classId}, function(res){
                if (res.code == 1) {
                    var html = '<option value="">- 请选择学员-</option>';
                    res.data.forEach(function(item){
                        html += '<option value="' + item.id + '">' + item.full_name + '</option>';
                    });
                    $('#users').html(html);
                } else {
                    layer.msg(res.info || '学员加载失败');
                }
                form.render('select');
            });
        }
    });
});


</script>
{/block}
